<!DOCTYPE html>
<html lang="zh-CN">
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width,initial-scale=1">
    <title>php基础 | Life &amp; Hobby</title>
    <meta name="generator" content="VuePress 1.6.0">
    <link rel="png" href="/icon.png">
    <meta name="description" content="">
    <meta name="theme-color" content="#3eaf7c">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <link rel="preload" href="/assets/css/0.styles.23c5269e.css" as="style"><link rel="preload" href="/assets/js/app.443cfbf6.js" as="script"><link rel="preload" href="/assets/js/3.1a8b1c56.js" as="script"><link rel="preload" href="/assets/js/1.35aae7fc.js" as="script"><link rel="preload" href="/assets/js/24.fba12fb6.js" as="script"><link rel="prefetch" href="/assets/js/10.b89f2468.js"><link rel="prefetch" href="/assets/js/11.9c7cd056.js"><link rel="prefetch" href="/assets/js/12.9c0bfae8.js"><link rel="prefetch" href="/assets/js/13.bf1e5e5a.js"><link rel="prefetch" href="/assets/js/14.c484b2a0.js"><link rel="prefetch" href="/assets/js/15.8c07680a.js"><link rel="prefetch" href="/assets/js/16.23062341.js"><link rel="prefetch" href="/assets/js/17.ae61d754.js"><link rel="prefetch" href="/assets/js/18.6880cf60.js"><link rel="prefetch" href="/assets/js/19.ae0425d6.js"><link rel="prefetch" href="/assets/js/20.d1b6e796.js"><link rel="prefetch" href="/assets/js/21.cf5ea939.js"><link rel="prefetch" href="/assets/js/22.e18f8681.js"><link rel="prefetch" href="/assets/js/23.37328433.js"><link rel="prefetch" href="/assets/js/25.57a16ad9.js"><link rel="prefetch" href="/assets/js/26.4cca75d9.js"><link rel="prefetch" href="/assets/js/27.1d2f6922.js"><link rel="prefetch" href="/assets/js/28.96218882.js"><link rel="prefetch" href="/assets/js/29.a8fb07c8.js"><link rel="prefetch" href="/assets/js/30.381b61b5.js"><link rel="prefetch" href="/assets/js/31.34dff827.js"><link rel="prefetch" href="/assets/js/32.1aa7b174.js"><link rel="prefetch" href="/assets/js/33.366f0768.js"><link rel="prefetch" href="/assets/js/34.99c01ba7.js"><link rel="prefetch" href="/assets/js/35.397d40cf.js"><link rel="prefetch" href="/assets/js/36.96d956b6.js"><link rel="prefetch" href="/assets/js/37.b4035fd8.js"><link rel="prefetch" href="/assets/js/38.fd449926.js"><link rel="prefetch" href="/assets/js/39.1286c93d.js"><link rel="prefetch" href="/assets/js/4.bbe797fb.js"><link rel="prefetch" href="/assets/js/40.165f9e26.js"><link rel="prefetch" href="/assets/js/41.5f719582.js"><link rel="prefetch" href="/assets/js/42.aff65ebb.js"><link rel="prefetch" href="/assets/js/43.6831adb0.js"><link rel="prefetch" href="/assets/js/44.4bc90034.js"><link rel="prefetch" href="/assets/js/45.9f777eb7.js"><link rel="prefetch" href="/assets/js/46.fe0cbaaa.js"><link rel="prefetch" href="/assets/js/47.a1586b31.js"><link rel="prefetch" href="/assets/js/48.c1c18fea.js"><link rel="prefetch" href="/assets/js/49.17462277.js"><link rel="prefetch" href="/assets/js/5.6f49a424.js"><link rel="prefetch" href="/assets/js/50.3c30e918.js"><link rel="prefetch" href="/assets/js/51.123fc8f8.js"><link rel="prefetch" href="/assets/js/52.2257ed73.js"><link rel="prefetch" href="/assets/js/53.625d9e7f.js"><link rel="prefetch" href="/assets/js/54.8547cd19.js"><link rel="prefetch" href="/assets/js/55.f0356ada.js"><link rel="prefetch" href="/assets/js/56.f12e898e.js"><link rel="prefetch" href="/assets/js/57.257a9d06.js"><link rel="prefetch" href="/assets/js/58.b5d5ef04.js"><link rel="prefetch" href="/assets/js/59.ac1d2e70.js"><link rel="prefetch" href="/assets/js/6.7b8c6394.js"><link rel="prefetch" href="/assets/js/60.c3bb3a41.js"><link rel="prefetch" href="/assets/js/61.a324e266.js"><link rel="prefetch" href="/assets/js/62.377390be.js"><link rel="prefetch" href="/assets/js/63.87e07808.js"><link rel="prefetch" href="/assets/js/64.a6993946.js"><link rel="prefetch" href="/assets/js/65.99e40bc6.js"><link rel="prefetch" href="/assets/js/66.6833c503.js"><link rel="prefetch" href="/assets/js/67.e13a348f.js"><link rel="prefetch" href="/assets/js/68.5ce7adeb.js"><link rel="prefetch" href="/assets/js/69.642cde0f.js"><link rel="prefetch" href="/assets/js/7.afeb76e6.js"><link rel="prefetch" href="/assets/js/70.814cf983.js"><link rel="prefetch" href="/assets/js/71.85d1770e.js"><link rel="prefetch" href="/assets/js/72.7d58fff3.js"><link rel="prefetch" href="/assets/js/73.a7a32798.js"><link rel="prefetch" href="/assets/js/8.d6924890.js"><link rel="prefetch" href="/assets/js/9.7af42793.js">
    <link rel="stylesheet" href="/assets/css/0.styles.23c5269e.css">
  </head>
  <body>
    <div id="app" data-server-rendered="true"><div class="theme-container" data-v-2d5f533b><div data-v-2d5f533b><div id="loader-wrapper" class="loading-wrapper" data-v-d48f4d20 data-v-2d5f533b data-v-2d5f533b><div class="loader-main" data-v-d48f4d20><div data-v-d48f4d20></div><div data-v-d48f4d20></div><div data-v-d48f4d20></div><div data-v-d48f4d20></div></div> <!----> <!----></div> <div class="password-shadow password-wrapper-out" style="display:none;" data-v-64685f0e data-v-2d5f533b data-v-2d5f533b><h3 class="title" style="display:none;" data-v-64685f0e data-v-64685f0e>Life &amp; Hobby</h3> <!----> <label id="box" class="inputBox" style="display:none;" data-v-64685f0e data-v-64685f0e><input type="password" value="" data-v-64685f0e> <span data-v-64685f0e>Konck! Knock!</span> <button data-v-64685f0e>OK</button></label> <div class="footer" style="display:none;" data-v-64685f0e data-v-64685f0e><span data-v-64685f0e><i class="iconfont reco-theme" data-v-64685f0e></i> <a target="blank" href="https://vuepress-theme-reco.recoluan.com" data-v-64685f0e>vuePress-theme-reco</a></span> <span data-v-64685f0e><i class="iconfont reco-copyright" data-v-64685f0e></i> <a data-v-64685f0e><span data-v-64685f0e>柚子</span>
            
          <span data-v-64685f0e>2018 - </span>
          2021
        </a></span></div></div> <div class="hide" data-v-2d5f533b><header class="navbar" data-v-2d5f533b><div class="sidebar-button"><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" role="img" viewBox="0 0 448 512" class="icon"><path fill="currentColor" d="M436 124H12c-6.627 0-12-5.373-12-12V80c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12zm0 160H12c-6.627 0-12-5.373-12-12v-32c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12zm0 160H12c-6.627 0-12-5.373-12-12v-32c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12z"></path></svg></div> <a href="/" class="home-link router-link-active"><!----> <span class="site-name">Life &amp; Hobby</span></a> <div class="links"><div class="color-picker"><a class="color-button"><i class="iconfont reco-color"></i></a> <div class="color-picker-menu" style="display:none;"><div class="mode-options"><h4 class="title">Choose mode</h4> <ul class="color-mode-options"><li class="dark">dark</li><li class="auto active">auto</li><li class="light">light</li></ul></div></div></div> <div class="search-box"><i class="iconfont reco-search"></i> <input aria-label="Search" autocomplete="off" spellcheck="false" value=""> <!----></div> <nav class="nav-links can-hide"><div class="nav-item"><a href="/tag/" class="nav-link"><i class="iconfont reco-tag"></i>
  Tag
</a></div><div class="nav-item"><div class="dropdown-wrapper"><a class="dropdown-title"><span class="title"><i class="iconfont reco-blog"></i>
      Category
    </span> <span class="arrow right"></span></a> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><!----> <a href="/Category/zhaiji/index.html" class="nav-link"><i class="iconfont undefined"></i>
  摘记
</a></li><li class="dropdown-item"><!----> <a href="/Category/suibi/index.html" class="nav-link"><i class="iconfont undefined"></i>
  随笔
</a></li></ul></div></div><div class="nav-item"><div class="dropdown-wrapper"><a class="dropdown-title"><span class="title"><i class="iconfont reco-blog"></i>
      前端基础
    </span> <span class="arrow right"></span></a> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><!----> <a href="/web/vscode/" class="nav-link"><i class="iconfont undefined"></i>
  开发环境
</a></li><li class="dropdown-item"><!----> <a href="/web/htmls/" class="nav-link"><i class="iconfont undefined"></i>
  html基础
</a></li><li class="dropdown-item"><!----> <a href="/web/css/" class="nav-link"><i class="iconfont undefined"></i>
  css基础
</a></li><li class="dropdown-item"><!----> <a href="/web/jsg/" class="nav-link"><i class="iconfont undefined"></i>
  javaScript
</a></li><li class="dropdown-item"><!----> <a href="/web/kuayu/" class="nav-link"><i class="iconfont undefined"></i>
  前端跨域
</a></li><li class="dropdown-item"><!----> <a href="/web/typeScript/typeScript.html" class="nav-link"><i class="iconfont undefined"></i>
  typeScript
</a></li></ul></div></div><div class="nav-item"><div class="dropdown-wrapper"><a class="dropdown-title"><span class="title"><i class="iconfont reco-other"></i>
      前端框架
    </span> <span class="arrow right"></span></a> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><!----> <a href="/frame/vue/vuecli.html" class="nav-link"><i class="iconfont undefined"></i>
  Vue
</a></li><li class="dropdown-item"><!----> <a href="/frame/react/" class="nav-link"><i class="iconfont undefined"></i>
  React
</a></li><li class="dropdown-item"><!----> <a href="/frame/Wechat/Wechat.html" class="nav-link"><i class="iconfont undefined"></i>
  Wechat
</a></li></ul></div></div><div class="nav-item"><div class="dropdown-wrapper"><a class="dropdown-title"><span class="title"><i class="iconfont reco-three"></i>
      工具集合
    </span> <span class="arrow right"></span></a> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><!----> <a href="/Server/node/node1.html" class="nav-link"><i class="iconfont undefined"></i>
  nodeJs
</a></li><li class="dropdown-item"><!----> <a href="/Server/php/phpjieshao.html" class="nav-link"><i class="iconfont undefined"></i>
  php
</a></li><li class="dropdown-item"><!----> <a href="/Server/git/git1.html" class="nav-link"><i class="iconfont undefined"></i>
  gitee
</a></li><li class="dropdown-item"><!----> <a href="/Server/cmd/" class="nav-link"><i class="iconfont undefined"></i>
  cmd
</a></li><li class="dropdown-item"><!----> <a href="/Server/LayaAir2/" class="nav-link"><i class="iconfont undefined"></i>
  LayaAir2
</a></li><li class="dropdown-item"><!----> <a href="/Server/three/" class="nav-link"><i class="iconfont undefined"></i>
  three
</a></li></ul></div></div><div class="nav-item"><div class="dropdown-wrapper"><a class="dropdown-title"><span class="title"><i class="iconfont reco-coding"></i>
      数据库
    </span> <span class="arrow right"></span></a> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><!----> <a href="/database/mysql/" class="nav-link"><i class="iconfont undefined"></i>
  mysql
</a></li><li class="dropdown-item"><!----> <a href="/database/mongodb/" class="nav-link"><i class="iconfont undefined"></i>
  mongo
</a></li></ul></div></div><div class="nav-item"><a href="https://gitee.com/yongqi666" target="_blank" rel="noopener noreferrer" class="nav-link external"><i class="iconfont reco-mayun"></i>
  gitee
  <svg xmlns="http://www.w3.org/2000/svg" aria-labelledby="outbound-link-title" role="img" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><title id="outbound-link-title">(opens new window)</title> <path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg></a></div> <!----></nav></div></header> <div class="sidebar-mask" data-v-2d5f533b></div> <aside class="sidebar" data-v-2d5f533b><div class="personal-info-wrapper" data-v-ca798c94 data-v-2d5f533b><img src="/image.jpg" alt="author-avatar" class="personal-img" data-v-ca798c94> <h3 class="name" data-v-ca798c94>
    柚子
  </h3> <div class="num" data-v-ca798c94><div data-v-ca798c94><h3 data-v-ca798c94>30</h3> <h6 data-v-ca798c94>文章</h6></div> <div data-v-ca798c94><h3 data-v-ca798c94>15</h3> <h6 data-v-ca798c94>标签</h6></div></div> <hr data-v-ca798c94></div> <nav class="nav-links"><div class="nav-item"><a href="/tag/" class="nav-link"><i class="iconfont reco-tag"></i>
  Tag
</a></div><div class="nav-item"><div class="dropdown-wrapper"><a class="dropdown-title"><span class="title"><i class="iconfont reco-blog"></i>
      Category
    </span> <span class="arrow right"></span></a> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><!----> <a href="/Category/zhaiji/index.html" class="nav-link"><i class="iconfont undefined"></i>
  摘记
</a></li><li class="dropdown-item"><!----> <a href="/Category/suibi/index.html" class="nav-link"><i class="iconfont undefined"></i>
  随笔
</a></li></ul></div></div><div class="nav-item"><div class="dropdown-wrapper"><a class="dropdown-title"><span class="title"><i class="iconfont reco-blog"></i>
      前端基础
    </span> <span class="arrow right"></span></a> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><!----> <a href="/web/vscode/" class="nav-link"><i class="iconfont undefined"></i>
  开发环境
</a></li><li class="dropdown-item"><!----> <a href="/web/htmls/" class="nav-link"><i class="iconfont undefined"></i>
  html基础
</a></li><li class="dropdown-item"><!----> <a href="/web/css/" class="nav-link"><i class="iconfont undefined"></i>
  css基础
</a></li><li class="dropdown-item"><!----> <a href="/web/jsg/" class="nav-link"><i class="iconfont undefined"></i>
  javaScript
</a></li><li class="dropdown-item"><!----> <a href="/web/kuayu/" class="nav-link"><i class="iconfont undefined"></i>
  前端跨域
</a></li><li class="dropdown-item"><!----> <a href="/web/typeScript/typeScript.html" class="nav-link"><i class="iconfont undefined"></i>
  typeScript
</a></li></ul></div></div><div class="nav-item"><div class="dropdown-wrapper"><a class="dropdown-title"><span class="title"><i class="iconfont reco-other"></i>
      前端框架
    </span> <span class="arrow right"></span></a> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><!----> <a href="/frame/vue/vuecli.html" class="nav-link"><i class="iconfont undefined"></i>
  Vue
</a></li><li class="dropdown-item"><!----> <a href="/frame/react/" class="nav-link"><i class="iconfont undefined"></i>
  React
</a></li><li class="dropdown-item"><!----> <a href="/frame/Wechat/Wechat.html" class="nav-link"><i class="iconfont undefined"></i>
  Wechat
</a></li></ul></div></div><div class="nav-item"><div class="dropdown-wrapper"><a class="dropdown-title"><span class="title"><i class="iconfont reco-three"></i>
      工具集合
    </span> <span class="arrow right"></span></a> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><!----> <a href="/Server/node/node1.html" class="nav-link"><i class="iconfont undefined"></i>
  nodeJs
</a></li><li class="dropdown-item"><!----> <a href="/Server/php/phpjieshao.html" class="nav-link"><i class="iconfont undefined"></i>
  php
</a></li><li class="dropdown-item"><!----> <a href="/Server/git/git1.html" class="nav-link"><i class="iconfont undefined"></i>
  gitee
</a></li><li class="dropdown-item"><!----> <a href="/Server/cmd/" class="nav-link"><i class="iconfont undefined"></i>
  cmd
</a></li><li class="dropdown-item"><!----> <a href="/Server/LayaAir2/" class="nav-link"><i class="iconfont undefined"></i>
  LayaAir2
</a></li><li class="dropdown-item"><!----> <a href="/Server/three/" class="nav-link"><i class="iconfont undefined"></i>
  three
</a></li></ul></div></div><div class="nav-item"><div class="dropdown-wrapper"><a class="dropdown-title"><span class="title"><i class="iconfont reco-coding"></i>
      数据库
    </span> <span class="arrow right"></span></a> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><!----> <a href="/database/mysql/" class="nav-link"><i class="iconfont undefined"></i>
  mysql
</a></li><li class="dropdown-item"><!----> <a href="/database/mongodb/" class="nav-link"><i class="iconfont undefined"></i>
  mongo
</a></li></ul></div></div><div class="nav-item"><a href="https://gitee.com/yongqi666" target="_blank" rel="noopener noreferrer" class="nav-link external"><i class="iconfont reco-mayun"></i>
  gitee
  <svg xmlns="http://www.w3.org/2000/svg" aria-labelledby="outbound-link-title" role="img" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><title id="outbound-link-title">(opens new window)</title> <path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg></a></div> <!----></nav> <ul class="sidebar-links"><li><section class="sidebar-group collapsable depth-0"><p class="sidebar-heading open"><span>php</span> <span class="arrow down"></span></p> <ul class="sidebar-links sidebar-group-items"><li><a href="/Server/php/phpjieshao.html" class="sidebar-link">php介绍</a></li><li><a href="/Server/php/php1.html" aria-current="page" class="active sidebar-link">php基础</a></li><li><a href="/Server/php/php2.html" class="sidebar-link">php 环境安装</a></li></ul></section></li></ul> </aside> <div class="password-shadow password-wrapper-in" style="display:none;" data-v-64685f0e data-v-2d5f533b><h3 class="title" style="display:none;" data-v-64685f0e data-v-64685f0e></h3> <!----> <label id="box" class="inputBox" style="display:none;" data-v-64685f0e data-v-64685f0e><input type="password" value="" data-v-64685f0e> <span data-v-64685f0e>Konck! Knock!</span> <button data-v-64685f0e>OK</button></label> <div class="footer" style="display:none;" data-v-64685f0e data-v-64685f0e><span data-v-64685f0e><i class="iconfont reco-theme" data-v-64685f0e></i> <a target="blank" href="https://vuepress-theme-reco.recoluan.com" data-v-64685f0e>vuePress-theme-reco</a></span> <span data-v-64685f0e><i class="iconfont reco-copyright" data-v-64685f0e></i> <a data-v-64685f0e><span data-v-64685f0e>柚子</span>
            
          <span data-v-64685f0e>2018 - </span>
          2021
        </a></span></div></div> <div data-v-2d5f533b><main class="page"><div class="page-title" style="display:none;"><h1 class="title">php基础</h1> <div data-v-3b7f5bdf><i class="iconfont reco-account" data-v-3b7f5bdf><span data-v-3b7f5bdf>柚子</span></i> <!----> <!----> <!----></div></div> <div class="theme-reco-content content__default" style="display:none;"><h2 id="php基础"><a href="#php基础" class="header-anchor">#</a> php基础</h2> <h3 id="输出方式的几种"><a href="#输出方式的几种" class="header-anchor">#</a> 输出方式的几种</h3> <div class="language-php extra-class"><pre class="language-php"><code><span class="token keyword">echo</span> <span class="token single-quoted-string string">'字符串'</span><span class="token punctuation">;</span>   <span class="token comment">// 输出字符串</span>
<span class="token function">var_dump</span><span class="token punctuation">(</span><span class="token variable">$arr</span><span class="token punctuation">)</span><span class="token punctuation">;</span>   <span class="token comment">// 输出类型</span>
<span class="token keyword">print</span><span class="token punctuation">(</span><span class="token single-quoted-string string">'字符串'</span><span class="token punctuation">)</span><span class="token punctuation">;</span>   <span class="token comment">// 输出字符串</span>
<span class="token function">print_r</span><span class="token punctuation">(</span><span class="token variable">$arr</span><span class="token punctuation">)</span><span class="token punctuation">;</span>   <span class="token comment">// 输出类型</span>
</code></pre></div><h3 id="php数据类型"><a href="#php数据类型" class="header-anchor">#</a> php数据类型</h3> <ol><li>标量类型  简单类型  值类型  基本类型</li></ol> <blockquote><p>1、string  2、bool  3、int  4、float</p></blockquote> <ol start="2"><li>符合类型  复杂类型  引用类型</li></ol> <blockquote><p>1、array  2、object   3、callback</p></blockquote> <ol start="3"><li>特殊类型</li></ol> <blockquote><p>1、null  2、resource</p></blockquote> <h3 id="php数据交互"><a href="#php数据交互" class="header-anchor">#</a> php数据交互</h3> <ol><li>数据是什么  name='li'&amp;email='2489919598@qq.com'</li> <li>是谁发送   url?id=3  from  src  ajax  urlencode  方式  get  post   客户端</li> <li>谁接收  php java node   服务端</li> <li>用什么接收   预定义变量</li></ol> <h3 id="php超全局变量"><a href="#php超全局变量" class="header-anchor">#</a> php超全局变量</h3> <ul><li>$_GET  --- get变量</li> <li>$_POST  --- post变量</li> <li>$_SERVER -- 服务器和执行环境</li> <li>$_FILES -- HTTP 文件上传</li> <li>$_REQUEST -- HTTP request 变量</li> <li>$_SESSION  --- session变量</li> <li>$_COOKIE -- http Cookie</li></ul> <h3 id="phpcookie和session"><a href="#phpcookie和session" class="header-anchor">#</a> phpcookie和session</h3> <blockquote><p>cookie 前后都有    4kb     兼容好  多页面   设置过期
session 服务端  相对安全   根据服务端设置 2M-20M   多页面  关闭浏览器
localstorage  前端（h5）  5M-20M      一般   多页面<br>
sessiontorage  前端（h5）  5M-20M      一般   单页面   关闭浏览器
使用之前要开启 session_start();</p></blockquote> <h3 id="php流程控制"><a href="#php流程控制" class="header-anchor">#</a> php流程控制</h3> <blockquote><p>require  致命 （不会继续执行脚本）
include  警告 （继续执行脚本）       引入多次执行多次
require_once<br>
include_once                       引入一次执行一次</p></blockquote> <h3 id="php中常用函数"><a href="#php中常用函数" class="header-anchor">#</a> php中常用函数</h3> <div class="language-php extra-class"><pre class="language-php"><code><span class="token keyword">isset</span><span class="token punctuation">(</span><span class="token variable">$a</span><span class="token punctuation">)</span><span class="token punctuation">;</span>   <span class="token comment">// 判断是否存在</span>
<span class="token keyword">unset</span><span class="token punctuation">(</span><span class="token variable">$a</span><span class="token punctuation">)</span><span class="token punctuation">;</span>   <span class="token comment">//切断联系</span>
<span class="token function">gettype</span><span class="token punctuation">(</span><span class="token punctuation">)</span>    <span class="token comment">// 判断类型</span>
<span class="token function">json_encode</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>   <span class="token comment">// 对数据进行js编码</span>
<span class="token function">json_decode</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>   <span class="token comment">// 对json数据进行解码</span>
<span class="token function">preg_match</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>    <span class="token comment">// 用来匹配正则   *(0||n+)  +(1||n+)  ?(0||1)</span>
<span class="token function">range</span><span class="token punctuation">(</span><span class="token single-quoted-string string">'A'</span><span class="token punctuation">,</span><span class="token single-quoted-string string">'z'</span><span class="token punctuation">)</span><span class="token punctuation">;</span>  <span class="token comment">// 所有大写字母</span>
</code></pre></div><h3 id="php判断数据类型"><a href="#php判断数据类型" class="header-anchor">#</a> php判断数据类型</h3> <div class="language-php extra-class"><pre class="language-php"><code><span class="token function">is_int</span><span class="token punctuation">(</span><span class="token punctuation">)</span>    <span class="token comment">// 是否是整形</span>
<span class="token function">is_array</span><span class="token punctuation">(</span><span class="token punctuation">)</span>   <span class="token comment">// 是否是数组</span>
<span class="token function">is_float</span><span class="token punctuation">(</span><span class="token punctuation">)</span>    <span class="token comment">// 是否是浮点数</span>
<span class="token keyword">empty</span><span class="token punctuation">(</span><span class="token punctuation">)</span>    <span class="token comment">//检查变量是否为空</span>
</code></pre></div><h3 id="php数学函数"><a href="#php数学函数" class="header-anchor">#</a> php数学函数</h3> <div class="language-php extra-class"><pre class="language-php"><code><span class="token function">abs</span><span class="token punctuation">(</span><span class="token punctuation">)</span>  <span class="token comment">// 取绝对值</span>
<span class="token function">ceil</span><span class="token punctuation">(</span><span class="token punctuation">)</span>  <span class="token comment">// 向上取整</span>
<span class="token function">floor</span><span class="token punctuation">(</span><span class="token punctuation">)</span>  <span class="token comment">// 向下取整</span>
<span class="token function">pow</span><span class="token punctuation">(</span>x<span class="token punctuation">,</span>n<span class="token punctuation">)</span>   <span class="token comment">// 返回x的n次方</span>
<span class="token function">round</span><span class="token punctuation">(</span><span class="token punctuation">)</span>   <span class="token comment">// 四舍五入</span>
<span class="token function">max</span><span class="token punctuation">(</span><span class="token punctuation">)</span>    <span class="token comment">// 最大值</span>
<span class="token function">min</span><span class="token punctuation">(</span><span class="token punctuation">)</span>    <span class="token comment">// 最小值</span>
<span class="token function">rand</span><span class="token punctuation">(</span><span class="token punctuation">)</span>    <span class="token comment">// 取随机数</span>
<span class="token function">mt_rand</span><span class="token punctuation">(</span><span class="token punctuation">)</span>   <span class="token comment">// 取随机数  比rand快四倍</span>
<span class="token function">md5</span><span class="token punctuation">(</span><span class="token punctuation">)</span>  <span class="token comment">// 字符串方法  对数据进行加密  32位16进制不可逆的字符串</span>
</code></pre></div><h3 id="php字符串方法"><a href="#php字符串方法" class="header-anchor">#</a> php字符串方法</h3> <div class="language-php extra-class"><pre class="language-php"><code><span class="token function">strlen</span><span class="token punctuation">(</span><span class="token punctuation">)</span>  <span class="token comment">//获取字符串长度(中文1:3)</span>
<span class="token function">mb_strlen</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token comment">// 获取字符串长度可以获取中文(中文1:1)</span>
<span class="token function">str_split</span><span class="token punctuation">(</span><span class="token punctuation">)</span>  <span class="token comment">// 通过指定长度将字符串转为数组</span>
<span class="token function">explode</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token comment">// 切割通过指定字符将字符串转为数组（指定字符不出现）</span>
<span class="token function">substr</span><span class="token punctuation">(</span>string<span class="token punctuation">,</span><span class="token single-quoted-string string">'开始位置'</span><span class="token punctuation">,</span>长度<span class="token punctuation">)</span> <span class="token comment">// 截取字符串</span>
</code></pre></div><h3 id="php数组方法"><a href="#php数组方法" class="header-anchor">#</a> php数组方法</h3> <div class="language-php extra-class"><pre class="language-php"><code><span class="token function">is_array</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span> <span class="token comment">//判断是否是数组0</span>
<span class="token function">count</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span> <span class="token comment">//数组长度</span>
<span class="token function">in_array</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span> <span class="token comment">//判断数组中是否存在某个值</span>
<span class="token function">array_keys</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span> <span class="token comment">//返回数组中所有的key值</span>
<span class="token function">array_values</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span> <span class="token comment">//返回数组中所有的value值</span>
<span class="token function">array_pop</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span> <span class="token comment">//在数组尾部删除一项（改变）</span>
<span class="token function">array_push</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span> <span class="token comment">//在数组尾部添加一项（改变）</span>
<span class="token function">array_unshift</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span> <span class="token comment">//在数组头部添加元素（改变）</span>
<span class="token function">array_shift</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span> <span class="token comment">//在数组头部删除元素（改变）</span>
<span class="token function">array_unique</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span> <span class="token comment">//数组去重</span>
<span class="token function">array_reverse</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span> <span class="token comment">//数组反转</span>
<span class="token function">array_key_exists</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span> <span class="token comment">//判断键名(key)是否在数组中存在</span>
<span class="token function">array_chunk</span><span class="token punctuation">(</span> <span class="token variable">$arr</span><span class="token punctuation">,</span> 长度<span class="token punctuation">)</span><span class="token punctuation">;</span> <span class="token comment">//分割数组</span>
<span class="token function">array_merge</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span> <span class="token comment">//合并数组</span>
<span class="token function">implode</span><span class="token punctuation">(</span><span class="token variable">$newArr</span><span class="token punctuation">,</span><span class="token single-quoted-string string">''</span><span class="token punctuation">)</span><span class="token punctuation">;</span> <span class="token comment">//数组转字符串</span>
<span class="token function">sort</span><span class="token punctuation">(</span><span class="token punctuation">)</span>  <span class="token comment">//数组排序从小到多大 不保持对应关系</span>
<span class="token function">asort</span><span class="token punctuation">(</span><span class="token punctuation">)</span>  <span class="token comment">//数组排序从小到多大 保持对应关系</span>
<span class="token function">rsort</span><span class="token punctuation">(</span><span class="token punctuation">)</span>  <span class="token comment">//数组排序从小到多大 保持对应关系</span>
</code></pre></div></div> <footer class="page-edit" style="display:none;"><!----> <!----></footer> <!----> <!----> <!----></main> <!----></div></div></div></div><div class="global-ui"><div class="back-to-ceiling" style="right:1rem;bottom:6rem;width:2.5rem;height:2.5rem;border-radius:.25rem;line-height:2.5rem;display:none;" data-v-c6073ba8 data-v-c6073ba8><svg t="1574745035067" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="5404" class="icon" data-v-c6073ba8><path d="M526.60727968 10.90185116a27.675 27.675 0 0 0-29.21455937 0c-131.36607665 82.28402758-218.69155461 228.01873535-218.69155402 394.07834331a462.20625001 462.20625001 0 0 0 5.36959153 69.94390903c1.00431239 6.55289093-0.34802892 13.13561351-3.76865779 18.80351572-32.63518765 54.11355614-51.75690182 118.55860487-51.7569018 187.94566865a371.06718723 371.06718723 0 0 0 11.50484808 91.98906777c6.53300375 25.50556257 41.68394495 28.14064038 52.69160883 4.22606766 17.37162448-37.73630017 42.14135425-72.50938081 72.80769204-103.21549295 2.18761121 3.04276886 4.15646224 6.24463696 6.40373557 9.22774369a1871.4375 1871.4375 0 0 0 140.04691725 5.34970492 1866.36093723 1866.36093723 0 0 0 140.04691723-5.34970492c2.24727335-2.98310674 4.21612437-6.18497483 6.3937923-9.2178004 30.66633723 30.70611158 55.4360664 65.4791928 72.80769147 103.21549355 11.00766384 23.91457269 46.15860503 21.27949489 52.69160879-4.22606768a371.15156223 371.15156223 0 0 0 11.514792-91.99901164c0-69.36717486-19.13165746-133.82216804-51.75690182-187.92578088-3.42062944-5.66790279-4.76302748-12.26056868-3.76865837-18.80351632a462.20625001 462.20625001 0 0 0 5.36959269-69.943909c-0.00994388-166.08943902-87.32547796-311.81420293-218.6915546-394.09823051zM605.93803103 357.87693858a93.93749974 93.93749974 0 1 1-187.89594924 6.1e-7 93.93749974 93.93749974 0 0 1 187.89594924-6.1e-7z" p-id="5405" data-v-c6073ba8></path><path d="M429.50777625 765.63860547C429.50777625 803.39355007 466.44236686 1000.39046097 512.00932183 1000.39046097c45.56695499 0 82.4922232-197.00623328 82.5015456-234.7518555 0-37.75494459-36.9345906-68.35043303-82.4922232-68.34111062-45.57627738-0.00932239-82.52019037 30.59548842-82.51086798 68.34111062z" p-id="5406" data-v-c6073ba8></path></svg></div><div class="reco-bgm-panel" data-v-39f9e6e0><audio id="bgm" src="/yishengduyi.mp3" data-v-39f9e6e0></audio> <div class="reco-float-box" style="bottom:200px;z-index:999999;display:none;" data-v-39f9e6e0 data-v-41bcba48 data-v-39f9e6e0><img src="/yishengduyi.jpg" data-v-39f9e6e0></div> <div class="reco-bgm-box" style="left:10px;bottom:10px;z-index:999999;" data-v-39f9e6e0 data-v-41bcba48 data-v-39f9e6e0><div class="reco-bgm-cover" style="background-image:url(/yishengduyi.jpg);" data-v-39f9e6e0><div class="mini-operation" style="display:none;" data-v-39f9e6e0><i class="reco-bgm reco-bgm-pause" style="display:none;" data-v-39f9e6e0></i> <i class="reco-bgm reco-bgm-play" style="display:none;" data-v-39f9e6e0></i></div> <div class="falut-message" style="display:none;" data-v-39f9e6e0>
          播放失败
        </div></div> <div class="reco-bgm-info" data-v-39f9e6e0 data-v-41bcba48 data-v-39f9e6e0><div class="info-box" data-v-39f9e6e0><i class="reco-bgm reco-bgm-music music" data-v-39f9e6e0></i>一生独一</div> <div class="info-box" data-v-39f9e6e0><i class="reco-bgm reco-bgm-artist" data-v-39f9e6e0></i>卢焱</div> <div class="reco-bgm-progress" data-v-39f9e6e0><div class="progress-bar" data-v-39f9e6e0><div class="bar" data-v-39f9e6e0></div></div></div> <div class="reco-bgm-operation" data-v-39f9e6e0><i class="reco-bgm reco-bgm-last last" data-v-39f9e6e0></i> <i class="reco-bgm reco-bgm-pause pause" style="display:none;" data-v-39f9e6e0></i> <i class="reco-bgm reco-bgm-play play" data-v-39f9e6e0></i> <i class="reco-bgm reco-bgm-next next" data-v-39f9e6e0></i> <i class="reco-bgm reco-bgm-volume1 volume" data-v-39f9e6e0></i> <i class="reco-bgm reco-bgm-mute mute" style="display:none;" data-v-39f9e6e0></i> <div class="volume-bar" data-v-39f9e6e0><div class="bar" data-v-39f9e6e0></div></div></div></div> <div class="reco-bgm-left-box" data-v-39f9e6e0 data-v-41bcba48 data-v-39f9e6e0><i class="reco-bgm reco-bgm-left" data-v-39f9e6e0></i></div></div></div><canvas id="vuepress-canvas-cursor"></canvas><div></div></div></div>
    <script src="/assets/js/app.443cfbf6.js" defer></script><script src="/assets/js/3.1a8b1c56.js" defer></script><script src="/assets/js/1.35aae7fc.js" defer></script><script src="/assets/js/24.fba12fb6.js" defer></script>
  </body>
</html>
